package com.joven.shelltest.utils.mapstrategy;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @Author: wzj
 * @Date: 2024/3/4 10:52
 */
@Service
@RequiredArgsConstructor
public class CalculationService {
    private final CalculationFactory calculationFactory;

    public int operateByStrategy(String strategy, int num1, int num2) {
        //calculationFactory.getCalculationStrategyMap().get(strategy)这里可能会出现空，所以要做一个容错处理
        return calculationFactory.getCalculationStrategyMap().get(strategy).operate(num1, num2);
    }
}
